package com.hnevc.sharerestuarnt;

import java.util.ArrayList;

public class ShareRestaurant {
	private ArrayList<Desk> desks = new ArrayList<>();
	private ArrayList<User> users = new ArrayList<>();
	
	private ArrayList<CookRestaurant> cookRestaurants = new ArrayList<>();

	public ArrayList<CookRestaurant> getCookRestaurants() {
		return cookRestaurants;
	}

	public ArrayList<Desk> getDesks() {
		return desks;
	}
	
	public ArrayList<User> getUsers() {
		return users;
	}

	public User login(User user){
		return user;
	}
	public void addCookeRestaurant(CookRestaurant cookRestaurant){
		cookRestaurants.add(cookRestaurant);
	}
	public void addUser(User user) {
		users.add(user);
	}
	public void addDesk(Desk desk){
		desks.add(desk);
	}
	
	public Desk openDesk(Desk desk,User user){
		System.out.println(user.getUserName() +"开台========");
		desk.clear();
		desk.setUser(user);
		return desk;
	}
	public void closeDesk(Desk desk){
		System.out.println("关台========");
		desk.clear();
	}

	public void payBill(Desk desk) {
		// TODO Auto-generated method stub
		System.out.println("结算");
		int sum=0;
		for(int i=0;i<desk.getOrder().getDishs().size();i++){
			Dish d = desk.getOrder().getDishs().get(i);
			sum += d.getPrice();
		}
		System.out.println("共消费"+sum+"元"+desk.getUser().getUserName()+"请付费："+sum+"元");
	}
	public void getFoodsForDesk(Desk desk) {
		System.out.println("系统根据order 到各个餐饮单位取餐");
		for(int i=0;i<desk.getOrder().getDishs().size();i++){
			Dish d = desk.getOrder().getDishs().get(i);
			d.getCookeRestaurant().cookDish(d);
			d.getCookeRestaurant().sendDish(d);
		}
	}


}
